import { Icon, Style, Fill, Stroke, Text } from 'ol/style.js'
import CircleStyle from 'ol/style/Circle'
const common = {
    fill: { color: '#55ff7f' },
    stroke: { color: '#fff', width: 2, lineDash: [] }
}
const icon = {
    src: '',
    anchor: [0.5, 0.5],
    size: [1, 1],
    scale: 1,
    rotation: 0,
    opacity: 1,
    anchorOrigin: 'bottom-left'
}
const text = {
    text: '',
    font: '16px Microsoft Yahei, Verdana, Geneva, sans-serif',
    offsetX: 0,
    offsetY: 0,
    fill: new Fill(common.fill),
    stroke: new Stroke(common.stroke)
}
const circle = {
    radius: 5,
    fill: {
        color: 'rgba(224,76,56,0.2)'
    },
    stroke: {
        color: '#1A1A1A',
        width: 1
    },
    geometry: function (feature) {
        return feature
    }
}
export default {
    init(param = {}) {
        const option = {}
        option.fill = this.fill(param.fill)
        option.stroke = this.stroke(param.stroke)
        if (param.icon) {
            option.image = param['isIcon'] ? this.icon(param.icon) : this.getCircle(param.icon)
        }
        if (param.text) {
            option.text = this.text(param.text)
        }
        return [new Style(option)]
    },
    text(param = {}) {
        const option = Object.assign({}, text, param)
        if (param.fill) {
            option.fill = this.fill(param.fill)
        }
        if (param.stroke) {
            option.stroke = this.stroke(param.stroke)
        }
        return new Text(option)
    },
    icon(param) {
        const option = Object.assign({}, icon, param)
        if (option.rotation) {
            option.rotation = (Math.PI / 180) * option.rotation
        }
        return new Icon(option)
    },
    getCircle(style = {}) {
        let option = Object.assign({}, circle)
        style = Object.assign(option, style)
        return new CircleStyle({
            radius: style.radius,
            fill: this.fill(style.fill),
            stroke: this.stroke(style.stroke)
        })
    },
    fill(param = {}) {
        return new Fill(Object.assign(common.fill, param))
    },
    stroke(param = {}) {
        return new Stroke(Object.assign({}, common.stroke, param))
    }
}
// # sourceMappingURL=style.js.map
